<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript">
$(function(){
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	$(".detail").colorbox({width:"95%", height:"70%", iframe:true});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get" action="">
<? include (Q::ini('custom_system/elements_dir'). 'searchform_element.php');?>
<table class="form_table">
	<tr>
		<th>日期</th>
		<td>
			<input type="text" name="begin_purchase_time" class="datepicker" value="<?=isset($_GET['begin_purchase_time'])?$_GET['begin_purchase_time']:'' ?>" /> to 
			<input type="text" name="end_purchase_time" class="datepicker" value="<?=isset($_GET['end_purchase_time'])?$_GET['end_purchase_time']:'' ?>" />
		</td>
	</tr>
	<tr>
		<th>财务审核时间</th>
		<td>
			<input type="text" name="begin_finance_audit_time" class="datepicker" value="<?=isset($_GET['begin_finance_audit_time'])?$_GET['begin_finance_audit_time']:'' ?>" /> to 
			<input type="text" name="end_finance_audit_time" class="datepicker" value="<?=isset($_GET['end_finance_audit_time'])?$_GET['end_finance_audit_time']:'' ?>" />
		</td>
	</tr>
	<tr>
		<th>仓库审核时间</th>
		<td>
			<input type="text" name="begin_storage_audit_time" class="datepicker" value="<?=isset($_GET['begin_storage_audit_time'])?$_GET['begin_storage_audit_time']:'' ?>" /> to 
			<input type="text" name="end_storage_audit_time" class="datepicker" value="<?=isset($_GET['end_storage_audit_time'])?$_GET['end_storage_audit_time']:'' ?>" />
		</td>
	</tr>
	<tr>
		<th>退货单号</th>
		<td><input type="text" name="purchase_order_number" value="<?=isset($_GET['purchase_order_number'])?$_GET['purchase_order_number']:''?>" /></td>
	</tr>
	<tr>
		<th>产品编号</th>
		<td><input type="text" name="product_basic_number" value="<?=isset($_GET['product_basic_number']) ? $_GET['product_basic_number'] : ''?>" /> 输入产品编号后六位例如：000001</td>
	</tr>
	<tr>
		<th>结款类型</th>
		<td>
			<select name="purchase_order_payment_type">
				<option value="">请选择..</option>
				<? foreach (Q::ini('custom_flag/purchase_order_payment_type') as $pt):?>
				<option value="<?=$pt['value']?>" <?if (isset($_GET['purchase_order_payment_type'])&&$_GET['purchase_order_payment_type']== $pt['value'])echo "selected='selected'" ?>><?=$pt['name']?></option>
				<? endforeach;?>
				</select>
		</td>
	</tr>
	<tr>
		<th>采购人员</th>
		<td>
			<select name="purchase_user_id">
				<option value="">请选择..</option>
				<?foreach ($user as $u):?>
				<option value="<?=$u['id']?>" <?if (isset($_GET['purchase_user_id'])&&$_GET['purchase_user_id']==$u['id'])echo "selected='selected'"?>><?=$u['name']?></option>
				<?endforeach;?>
			</select>
		</td>
	</tr>
	<tr>
		<th>仓库</th>
		<td>
			<select name="warehouse_id">
				<option value="">请选择..</option>
				<?foreach ($warehouse as $w):?>
				<option value="<?=$w['id']?>" <?if (isset($_GET['warehouse_id'])&&$_GET['warehouse_id']==$w['id'])echo "selected='selected'"?>><?=$w['name']?></option>
				<?endforeach;?>
			</select>
		</td>
	</tr>
	<tr>
		<th>状态</th>
		<td>
			<label><input type="checkbox" name="status[1]" value="1" <?if (isset($_GET['status']) && array_key_exists(1, $_GET['status'])) echo "checked='checked'";?> /> 待退</label>
			<label><input type="checkbox" name="status[4]" value="4" <?if (isset($_GET['status']) && array_key_exists(4, $_GET['status'])) echo "checked='checked'";?> /> 已退</label>
		</td>
	</tr>
	<tr>
		<th>财务审核</th>
		<td>
			<?foreach (Q::ini('custom_flag/purchase_order_finance_audit') as $fa):?>
			<label><input type="checkbox" name="finance_audit[<?=$fa['value']?>]" value="<?=$fa['value']?>" <?if (isset($_GET['finance_audit']) && array_key_exists($fa['value'], $_GET['finance_audit'])) echo "checked='checked'";?> /> <?=$fa['name']?></label>
			<?endforeach;?>
		</td>
	</tr>
	<tr>
		<th></th>
		<td><input type="submit" value="查询" class="button" /></td>
	</tr>
</table>
</form>
</fieldset>
<table width="100%" class="list_table">
	<tr>
		<th>退货单号</th>
		<th>仓库</th>
		<th>日期</th>
		<th>经手人</th>
		<th>结款类型</th>
		<th>状态</th>
		<th>财务审核时间</th>
		<th>仓库审核时间</th>
		<th>操作</th>
	</tr>
	<?foreach ($purchase_order as $po):?>
	<tr>
		<td><a class="detail" href="<?=url('Purchase::Order/Detail', array('id' => $po['id']))?>"><?=$po['number']?></a></td>
		<td><?=$po['warehouse_name']?></td>
		<td><?=substr($po['purchase_time'], 0, 10)?></td>
		<td><?=$po['purchase_user_name']?></td>
		<td><?=Helper_BSS_Normal::getIniOne('purchase_order_payment_type','value',$po['payment_type'],'name')?></td>
		<td><?if ($po['status'] == Q::ini('custom_flag/purchase_order_status/storaged/value')):?>已退<?else:?>待退<?endif;?></td>
		<td><?=substr($po['finance_audit_time'], 0, 10)?></td>
		<td><?=substr($po['storage_audit_time'], 0, 10)?></td>
		<td>
			<?if ($po['status'] != Q::ini('custom_flag/purchase_order_status/storaged/value')):?>
			<a href="<?=url('Purchase::Order/DrawbackEdit', array('id' => $po['id']))?>">修改</a>
			<?else:?>
			<font color="#aaaaaa">修改</font>
			<?endif;?>
		</td>
	</tr>
	<?endforeach;?>
</table>
<?=$page?>
搜索条件下的退货总价：RMB <strong><?=number_format($return_amount, 2)?></strong><br />
搜索条件下的退货数量：<strong><?=$return_quantity?></strong>
<?php $this->_endblock(); ?>